import 'package:flutter_yishop/constants/Constants.dart';
import 'package:sp_util/sp_util.dart';

class UserService{
  static List getUserInfo(){
    List userInfo;
    try{
      List userInfoData = SpUtil.getObjectList(Constants.USERINFO);
      userInfo = userInfoData;
    }catch(e){
      userInfo = [];
    }
    return userInfo;
  }

  static bool getUserLoginState(){
    List userInfo = UserService.getUserInfo();
    if(userInfo !=null && userInfo.length>0 && userInfo[0]["username"]!=""){
      return true;
    }
    return false;
  }

  static loginOut(){
    SpUtil.remove(Constants.USERINFO);
  }
}